const webpack = require('webpack');
const path = require('path');
const { merge } = require('webpack-merge');
const base = require('./webpack.base');

const { publicPath } = require('./constant');

module.exports = merge(base, {
  mode: 'development',
  devtool: 'cheap-module-source-map',
  devServer: {
    open: true,
    contentBase: path.join(__dirname, publicPath, 'dist'), // devServer的根目录文件夹
    compress: true,
    openPage: '#/home',
    quiet: true,
    port: 9001,
    hot: true,
  },
  // optimization: {
  //   splitChunks: {
  //     cacheGroups: {
  //       commons: {
  //         test: /[\\/]node_modules[\\/]/,
  //         name: 'vendors',
  //         chunks: 'all',
  //       },
  //     },
  //   },
  // },
  module: {
    rules: [
      // {
      //   test: /\.(js|jsx|ts|tsx)$/,
      //   exclude: /node_modules/,
      //   use: [
      //     {
      //       loader: 'eslint-loader',
      //       options: {
      //         enforce: 'pre',
      //         fix: true,
      //       },
      //     },
      //   ],
      // },
    ],
  },
  plugins: [
    new webpack.ProgressPlugin(), // 显示打包进度
    new webpack.BannerPlugin({
      banner: 'Copyright by xxx,Contacts:xxx@qq.com',
    }),
    // new webpack.HotModuleReplacementPlugin(), // 热更新插件
  ],
});
